package com.pennywise.common.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * 统一响应结果类
 * @param <T> 响应数据类型
 */
@Data
@Accessors(chain = true)
@Schema(description = "统一响应结果")
public class Result<T> {
    
    public static final int SUCCESS_CODE = 200;
    public static final int ERROR_CODE = 500;
    public static final String SUCCESS_MESSAGE = "success";
    
    @Schema(description = "状态码")
    private Integer code;
    
    @Schema(description = "提示信息")
    private String message;
    
    @Schema(description = "响应数据")
    private T data;
    
    public static <T> Result<T> success(T data) {
        return new Result<T>()
                .setCode(SUCCESS_CODE)
                .setMessage(SUCCESS_MESSAGE)
                .setData(data);
    }
    
    public static <T> Result<T> error(String message) {
        return error(ERROR_CODE, message);
    }
    
    public static <T> Result<T> error(Integer code, String message) {
        return new Result<T>()
                .setCode(code)
                .setMessage(message);
    }
} 